package ch13;

/**
 * Created by zhangyunqi on 2017/10/9.
 */
public class SortingT {
    public static void main(String[] args) {
        Comparable[] text = new Comparable[10];
        text[0] = (90);
        text[1] = (8);
        text[2] = (7);
        text[3] = (56);
        text[4] = (123);
        text[5] = (235);
        text[6] = (9);
        text[7] = (1);
        text[8] = (653);
        text[9] = (2307);
        System.out.println ( "insertionSort:" );
        System.out.println ( " " );
        System.out.print ( "排序之前：" );
        for (Comparable comparable : text) {
            System.out.print ( comparable + "  " );
        }
        Sorting.insertionSort ( text );
        System.out.println ( " " );
        System.out.print ( "排序之后：" );
        for (Comparable comparable : text) {
            System.out.print ( comparable + "  " );
        }
        Sorting.insertionSort ( text );
        System.out.println ( " " );
        System.out.println ( " " );

        System.out.print ( "bubbleSort:" );
        System.out.println ( " " );

        Sorting.bubbleSort ( text );
        System.out.println ( " " );
        System.out.print ( "排序之后：" );
        for (Comparable comparable : text) {
            System.out.print ( comparable + "  " );
        }


        System.out.println ( " " );
        System.out.println ( " " );
        System.out.println ( "quickSort" );
        System.out.println ( " " );

        Sorting.quickSort ( text ,0,text.length-1);
        System.out.println ( " " );
        System.out.print ( "排序之后：" );
        for (Comparable comparable : text) {
            System.out.print ( comparable + "  " );
        }
        Sorting.quickSort ( text, 0,text.length-1);


        System.out.println ( " " );
        System.out.println ( " " );
        System.out.println ( "mergeSort" );
        System.out.println ( " " );

        Sorting.mergeSort ( text ,0,text.length-1);
        System.out.println ( " " );
        System.out.print ( "排序之后：" );
        for (Comparable comparable : text) {
            System.out.print ( comparable + "  " );
        }
        Sorting.mergeSort ( text, 0,text.length-1);


        System.out.println ( " " );
        System.out.println ( " " );
        System.out.println ( "selectionSort" );
        System.out.println ( " " );

        Sorting.selectionSort ( text );
        System.out.println ( " " );
        System.out.print ( "排序之后：" );
        for (Comparable comparable : text) {
            System.out.print ( comparable + "  " );
        }
        Sorting.selectionSort ( text);
    }
}
